using System;
using System.Web.UI.WebControls;
using ConcursoCV.UI.Clases.ManejadoresControles;
using Curriculum.Services;

namespace Concurso.Clases.ManejadoresControles
{
	/// <summary>
	/// Summary description for ManejadorTextBox.
	/// </summary>
	public class ManejadorTextBox : ManejadorControles
	{
		public ManejadorTextBox()
		{
			//
			// TODO: Add constructor logic here
			//
		}
		public override void Cargar(WebControl ctrl, object value)
		{
			((TextBox)ctrl).Text = (string) value;
		}
		public override void Inicializar(WebControl ctrl, object value)
		{
			char separator = ':';
			string idAtributo = value.ToString().Split(separator)[1];
			VersionMetadatosService svc = new VersionMetadatosService();
			int longitud =  svc.ObtenerAtributoMetadato(idAtributo).Longitud;
			((TextBox)ctrl).MaxLength = longitud;
			ctrl.Width = 300;		
		}
		public override string GetValor(WebControl ctrl)
		{
			return ((TextBox)ctrl).Text;
		}
	}
}
